let fs = require("fs")
let ws = fs.createWriteStream('./2.txt', {
    highWaterMark: 3,
    flags: 'w',
    mode: 0o666,
    start: 0,
    encoding: 'utf8',
    autoClose: true
});
let n = 9;
function write(){
    let flag = true
    while(flag && n > 0){
        flag = ws.write(n + "")
        n--
        console.log(flag)
    }
}
ws.on('drain', ()=>{
    console.log('drain')
    write()
})
write()